package com.chat.datea.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.chat.datea.fragment.FindFragment;
import com.chat.datea.fragment.MusicClubFragment;
import com.chat.datea.fragment.UserCenterFragment;

import java.util.ArrayList;

/**
 * Created by dllo on 15/10/20.
 */
public class MainActivity_ViewPager_Adapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> fragments;
    private FragmentManager fManager;

    public MainActivity_ViewPager_Adapter(FragmentManager fm,FragmentManager chl) {
        super(chl);
        fManager = fm;
        initData();
    }

    private void initData() {
        fragments = new ArrayList<>();
        fragments.add(new UserCenterFragment());
        fragments.add(new MusicClubFragment(fManager));
        fragments.add(new FindFragment());
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.size() > 0 && fragments != null ? fragments.get(position) : null;
    }

    @Override
    public int getCount() {
        return fragments.size() > 0 && fragments != null ? fragments.size() : 0;
    }


}
